package com.woniu.market_stall.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.entity.Grade;
import com.woniu.market_stall.mapper.GradeMapper;
import com.woniu.market_stall.vo.GradeVo;
import com.woniu.market_stall.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class GradeService {


    @Autowired
    GradeMapper gradeMapper;

    public Grade queryGradeByKey(Integer id) {
        return gradeMapper.queryGradeByKey(id);
    }

    @Transactional
    public void modifyGrade(Grade gradeuu) {
        gradeMapper.updateGradeState(gradeuu);
        gradeMapper.updateGrade(gradeuu);
    }

    public void modify(Grade gradeuu) {
        gradeMapper.updateGrade(gradeuu);
    }


    public void add(GradeVo gradeVo) {
        gradeMapper.insertGrade(gradeVo);
    }

    @Transactional
    public void addGrade(GradeVo gradeVo) {
        gradeMapper.updateStateGrade(gradeVo);
        gradeMapper.insertGrade(gradeVo);
    }

    public int removeStallByKey(Long id) {

        int i = gradeMapper.delByPrimaryKey(id);
        return i;
    }

    public PageInfo<GradeVo> queryByPage(Integer now, Integer size, String name) {

        PageHelper.startPage(now,size);
        List<GradeVo> list = gradeMapper.selectManagerByName(name);
        return new PageInfo<>(list);
    }


}
